<template>
  <div class="comprehensive-box">
    <TitleBar
      title="资金统计"
      refresh
    />
    <div class="comprehensive-top">
      <div class="comprehensive-lf">
        <!-- <div
class="exportBtn"
             @click="exportBtn"
>导出数据</div> -->
        <div class="comprehensive-sel">
          <el-radio-group
            v-model="radio"
            @change="selBtn"
          >
            <el-radio-button label="全部" />
            <el-radio-button label="最近30天" />
            <el-radio-button label="最近90天" />
          </el-radio-group>
        </div>
      </div>
      <div class="sel-time">
        <el-date-picker
          v-model="value"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          @change="selTime"
        />
      </div>
      <!-- <div
        class="rig"
        @click="refBtn"
      >
        <div class="img">
          <img src="../../../icons/icon/刷新.png">
        </div>
        刷新
      </div> -->
    </div>
    <com-table ref="mychild" />
  </div>
</template>

<script>
import comTable from '../comptents/compre/table'
import { recentDate, nineDate } from '@/utils/util.js'
export default {
  components: {
    comTable
  },
  inject: ['reload'],
  data() {
    return {
      radio: '全部',
      value: ''
    }
  },
  methods: {
    // 导出
    exportBtn() { },
    // 刷新
    refBtn() {
      this.reload()
    },
    // 筛选时间
    selBtn() {
      // this.$refs.mychild.getUserData()
      if (this.radio === '最近30天') {
        this.$refs.mychild.getUserData(recentDate(30), recentDate(1))
      } else if (this.radio === '最近90天') {
        this.$refs.mychild.getUserData(nineDate(), recentDate(1))
      } else {
        this.$refs.mychild.getUserData()
      }
    },
    // 选择时间
    selTime() {
      if (this.value) {
        this.$refs.mychild.getUserData(this.value[0], this.value[1])
      } else {
        this.$refs.mychild.getUserData()
      }
    }
  }
}
</script>
